<template>
  <div id="carmanage">
    <h1 class="titleTag">车辆管理</h1>
    <el-form :inline="true" :model="ruleForm" ref="ruleForm" class="mt24">
      <el-form-item>
        <el-input v-model="ruleForm.number" placeholder="车牌号" size="small"></el-input>
      </el-form-item>
      <el-form-item>
        <el-select style="width: 144px;" v-model="ruleForm.value1" placeholder="车辆状态" size="small">
          <el-option width="100" v-for="item in ruleForm.options1" :key="item.value" :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select style="width: 144px;" v-model="ruleForm.value2" placeholder="绑定状态" size="small">
          <el-option width="100" v-for="item in ruleForm.options2" :key="item.value" :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select style="width: 144px;" v-model="ruleForm.value3" placeholder="车俩类型" size="small">
          <el-option width="100" v-for="item in ruleForm.options3" :key="item.value" :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-form-item>
          <el-date-picker type="datetime" placeholder="请选择创建时间" v-model="ruleForm.time" default-time="12:00:00"
            style="width: 100%;" size="small"></el-date-picker>
        </el-form-item>
      </el-form-item>
      <el-form-item>
        <el-select style="width: 144px;" v-model="ruleForm.value4" placeholder="绑定状态" size="small">
          <el-option width="100" v-for="item in ruleForm.options4" :key="item.value" :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select style="width: 144px;" v-model="ruleForm.value5" placeholder="运输证期限" size="small">
          <el-option width="100" v-for="item in ruleForm.options5" :key="item.value" :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select style="width: 144px;" v-model="ruleForm.value6" placeholder="审核状态" size="small">
          <el-option width="100" v-for="item in ruleForm.options6" :key="item.value" :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="query(2,10,1)" size="small">查询</el-button>
      </el-form-item>
      <el-form-item>
        <el-button size="small" @click="resetForm('ruleForm')">清空</el-button>
      </el-form-item>
      <el-form-item>
        <el-button size="small">新增</el-button>
      </el-form-item>
    </el-form>
    <div class="tableDetail">
      <el-table :data="tableData" height="634" border style="width: 100%;">
        <el-table-column header-align="center" label="车俩信息" min-width="250">
          <template slot-scope="data">
            <div class="fb"><span>车牌号</span><span>{{ data.row.carNo }}</span></div>
            <div class="fb"><span>车俩类型</span><span>{{ data.row.typeid }}</span></div>
            <div class="fb"><span>道路运输证号</span><span>{{ data.row.carrigerId }}</span></div>
            <div class="fb"><span>车辆载重</span><span>{{ data.row.number4 }}</span></div>
          </template>
        </el-table-column>
        <el-table-column header-align="center" label="绑定司机" min-width="280">
          <template slot-scope="data">
            <div class="fb"><span>绑定司机</span><span>{{ data.row.carOwner }}</span></div>
            <div class="fb"><span>司机电话</span><span>{{ data.row.phone }}</span></div>
          </template>
        </el-table-column>
        <el-table-column header-align="center" label="状态" min-width="186">
          <template slot-scope="data">
            <div class="fb"><span>审核状态</span><span>{{ data.row.number7 }}</span></div>
            <div class="fb"><span>车俩状态</span><span>{{ data.row.number8 }}</span></div>
            <div class="fb"><span>是否如网</span><span>{{ data.row.number9 }}</span></div>
            <div class="fb"><span>绑定状态</span><span>{{ data.row.number10 }}</span></div>
          </template>
        </el-table-column>
        <el-table-column header-align="center" label="证件查看" min-width="186">
          <template slot-scope="scope">
            <div class="fb"><span>行驶证</span>
              <el-button @click="handleClick(scope.row.firmImg)" type="text" size="small">查看</el-button>
            </div>
            <div class="fb"><span>道路运输许可证</span>
              <el-button @click="handleClick(scope.row.firmImg)" type="text" size="small">查看</el-button>
            </div>
          </template>
        </el-table-column>
        <el-table-column header-align="center" label="时间" min-width="260">
          <template slot-scope="data">
            <div class="fb"><span>启用时间</span><span>{{ data.row.startTime }}</span></div>
            <div class="fb"><span>停用时间</span><span>{{ data.row.endtTime }}</span></div>
          </template>
        </el-table-column>
        <el-table-column header-align="center" align="center" label="操作" min-width="100">
          <template slot-scope="scope">
            <!--  -->
            <div>
              <el-button @click="deleteSure(scope.row)" type="text" size="small">删除</el-button>
            </div>
            <div>
              <el-button type="text" size="small" @click="deleteSure(scope.row)">
                <router-link tag="i" :to="{path:'/carupload',query:{id: scope.row.idenid}}">编辑</router-link>
              </el-button>
            </div>
            <!-- <div>
              <el-button type="text" size="small" @click="deleteSure(scope.row.orderNumber)">
                <router-link tag="i" :to="{path:'/carupload',query:{id: scope.row.orderNumber}}">审核</router-link>
              </el-button>
            </div> -->
          </template>
        </el-table-column>
      </el-table>
    </div>

    <el-dialog title="证件" :visible.sync="dialogTableVisible">
      <img style="width:100%: overflow: hidden" :src="imgUrl" alt="" srcset="">
    </el-dialog>
    <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
      <span>确定要删除吗</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { apiCarList } from "@/utils/api";
export default {
  name: "carmanage",
  data() {
    return {
      dialogVisible: false,
      dialogTableVisible: false,
      imgUrl: "",
      ruleForm: {
        number: "",
        value1: "",
        value2: "",
        value3: "",
        value4: "",
        value5: "",
        value6: "",
        options1: [
          {
            value: "启用",
            label: "启用"
          },
          {
            value: "停用",
            label: "停用"
          }
        ],
        options2: [
          {
            value: "已绑定",
            label: "已绑定"
          },
          {
            value: "未绑定",
            label: "未绑定"
          }
        ],
        options3: [
          {
            value: "已绑定",
            label: "已绑定"
          },
          {
            value: "未绑定",
            label: "未绑定"
          }
        ],
        options4: [
          {
            value: "已入网",
            label: "已入网"
          },
          {
            value: "未入网",
            label: "未入网"
          }
        ],
        options5: [
          {
            value: "已过期",
            label: "已过期"
          },
          {
            value: "未过期",
            label: "未过期"
          }
        ],
        options6: [
          {
            value: "待审核",
            label: "待审核"
          },
          {
            value: "通过",
            label: "通过"
          },
          {
            value: "驳回",
            label: "驳回"
          }
        ],
        time: ""
      },
      tableData: [
        // {
        //   status: "待受理",
        //   number1: "D201911250001",
        //   number2: "普通货车",
        //   number3: "G1526555485699",
        //   number4: "20",
        //   number5: "15426333562",
        //   number6: "张三",
        //   number7: "通过",
        //   number8: "启用",
        //   number9: "已入网",
        //   number10: "已绑定",
        //   number11: "月结",
        //   number12: "煤炭",
        //   number13: "1000",
        //   number14: "吨",
        //   number16: "2019.11.28-14.:25",
        //   number17: "2019.11.28-14.:25"
        // },
        // {
        //   status: "待受理",
        //   number1: "D201911250001",
        //   number2: "普通货车",
        //   number3: "G1526555485699",
        //   number4: "20",
        //   number5: "15426333562",
        //   number6: "张三",
        //   number7: "通过",
        //   number8: "启用",
        //   number9: "已入网",
        //   number10: "已绑定",
        //   number11: "月结",
        //   number12: "煤炭",
        //   number13: "1000",
        //   number14: "吨",
        //   number16: "2019.11.28-14.:25",
        //   number17: "2019.11.28-14.:25"
        // },
        // {
        //   status: "待受理",
        //   number1: "D201911250001",
        //   number2: "普通货车",
        //   number3: "G1526555485699",
        //   number4: "20",
        //   number5: "15426333562",
        //   number6: "张三",
        //   number7: "通过",
        //   number8: "启用",
        //   number9: "已入网",
        //   number10: "已绑定",
        //   number11: "月结",
        //   number12: "煤炭",
        //   number13: "1000",
        //   number14: "吨",
        //   number16: "2019.11.28-14.:25",
        //   number17: "2019.11.28-14.:25"
        // }
      ]
    };
  },
  created() {},
  mounted() {
    this.query(1, 10, 1);
  },
  methods: {
    query(type, size, page) {
      apiCarList({
        carNo: type == 1 ? "" : this.number,
        status: "",
        pageSize: size,
        pageNumber: page
      })
        .then(res => {
          this.tableData = res.data.records;
        })
        .catch(error => {
          console.log(error);
        });
    },
    // 查看证件
    handleClick(val) {
      console.log(val);
      this.dialogTableVisible = true;
      this.imgUrl = val;
    },
    deleteSure() {
      this.dialogVisible = true;
    },
    // 清空
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
};
</script>

<style lang="scss" scoped>
#carmanage {
  min-height: 100%;
  background-color: #fff;
  padding: 24px;
  box-sizing: border-box;
  .tableDetail span {
    line-height: 35px;
  }
  .dialog .price {
    color: $red;
  }
}
</style>
